<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>



    <input type="text" id="i1">
    <input type="button" value="平方" onclick="fn()">
    <div></div>




<script>
    function fn(){
        //获取输入框元素
       let i = document.querySelector("#i1");
       //获取div元素
       let d = document.querySelector("div");
       //将i的值的平方赋值给d
       d.innerText = i.value*i.value;
    }
</script>
</body>
</html>